<template>

  <el-container class="bg">
    <el-main>
      <div class="screen-area" @change="listByCategory">
        <Screen ref="screen"></Screen>
      </div>
      <books class="books-area" ref="booksArea" style="margin-top: 20px">
      </books>
    </el-main>
  </el-container>
</template>

<script>

  import Screen from './Screen'
  import Books from './Book'

  export default {
    name: 'AppLibrary',
    components: {Screen, Books},
    methods: {
      listByCategory () {
        var _this = this
        var cid = null
        var rare = null
/*        var cid, rare;
        if(this.$refs.screen.cid.length == 0){
          this.cid = null;
        }
        else {
          this.cid = this.$refs.screen.cid
        }

        if(this.$refs.screen.rare.length == 0){
          this.rare = null;
        }
        else {
          this.rare = this.$refs.screen.rare
        }*/
        console.log(cid)
        console.log(rare)
/*        if (cid == null){
          this.$axios.get('/characters').then(resp => {
            if (resp && resp.status === 200) {
              _this.$refs.booksArea.books = resp.data
            }
          })
        }
        else */{
          var url = 'careers/' + cid + '/' + rare + '/characters'
          this.$axios.get(url).then(resp => {
            if (resp && resp.status === 200) {
              _this.$refs.booksArea.books = resp.data
            }
          })
        }
      },
    }
  }
</script>

<style scoped>
  .screen-area {
    width: 990px;
    margin-left: auto;
    margin-right: auto;
  }
  .books-area {
    width: 990px;
    margin-left: auto;
    margin-right: auto;
  }
</style>

